public class Solution345 {
    public String reverseVowels(String s) {
        char[] chars=s.toCharArray();
        int[] record=new int[300000];
        int count=0;
        for (int i=0;i<chars.length;i++){
            if (chars[i]=='a'||chars[i]=='e'||chars[i]=='i'||chars[i]=='o'||chars[i]=='u'
                ||chars[i]=='A'||chars[i]=='E'||chars[i]=='I'||chars[i]=='O'||chars[i]=='U'){
                count++;
                record[count]=i;
            }
        }
        for (int i=1,j=count;i<j;i++,j--){
            char temp=chars[record[i]];
            chars[record[i]]=chars[record[j]];
            chars[record[j]]=temp;
        }
        return String.valueOf(chars);
    }

    public static void main(String[] args) {
        System.out.println(new Solution345().reverseVowels("leetcode"));
    }
}
